package com.thb.pay.manage.comm.interceptor;

import com.thb.pay.api.sys.vo.resp.SysUserVo;
import com.thb.pay.core.interceptor.AbstractOperationLogInterceptor;
import com.thb.pay.core.logs.domain.OperationLogEntity;
import com.thb.pay.core.utils.ContextHolder;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @类名称 OperationLogInterceptor
 * @类描述 <pre>登入后，操作日志拦截【登入后面，权限前面】</pre>
 * @作者 lucky
 * @创建时间 2019/10/11
 * @版本 v1.01
 */
@Component
public class OperationLogInterceptor extends AbstractOperationLogInterceptor {
    @Override
    public Integer operatorPlate() {
        return OPERATOR_PLATEFORM_MANAGE;
    }

    @Override
    public void insertOperatorLog(HttpServletRequest request, HttpServletResponse response, OperationLogEntity operationLog) {
        operationLog.setUserId(ContextHolder.getUserId());
        operationLog.setUserName(((SysUserVo) ContextHolder.getUserInfo()).getUserName());
        logger.debug(String.format("operator.log.by.userId:%s.....logs:%s", ContextHolder.getUserId().toString(), ContextHolder.getUserInfo().toString()));
    }
}
